package xddq

import (
	"fmt"
	"time"
	D "websocket_apn/define"
	"websocket_apn/log"
	"websocket_apn/proto"
)

// 处理神躯信息
func (xd *XdDriver) CheckParaShenQuInfoData(allInfo D.ShenQuInfo) {
	timeNow := time.Now()
	for _, info := range allInfo.A {
		if info.Count >= 3 {
			//continue
		}
		if info.EndTime.After(timeNow) {
			log.Debugf("神躯神藏 %s 等级 %d 个 时间 %s", info.ID, info.Count, info.EndTime.Format("2006-01-02 15:04:05"))
			break
		} else {
			log.Debugf("神躯神藏 %s 等级 %d 个", info.ID, info.Count)
			xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_DIVINE_INSIGHT_BUILD_UPGRADE_REQ, fmt.Sprintf("08 %s", info.ID))) //升级
		}
	}
	for _, info := range allInfo.B {
		if info.Count >= 3 {
			continue
		}
		if info.EndTime.After(timeNow) {
			log.Debugf("神躯技能 %s 等级 %d 个 时间 %s", info.ID, info.Count, info.EndTime.Format("2006-01-02 15:04:05"))
			xd.ResetTaskByTime(231011, info.EndTime.Add(time.Second*5))
			break
		} else {
			log.Debugf("神躯技能 %s 等级 %d", info.ID, info.Count)
			xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_DIVINE_INSIGHT_INSPIRE_UPGRADE_REQ, fmt.Sprintf("08 %s", info.ID)))  //升级
			xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_DIVINE_INSIGHT_UNION_HELP_REQ, fmt.Sprintf("08 %s 10 01", info.ID))) //协助
		}
	}
}
